﻿Public Class MyAppointmentFormController
    Inherits AppointmentFormController

    Public Sub New(ByVal control As SchedulerControl, ByVal apt As Appointment)
        MyBase.New(control, apt)
    End Sub

#Region "GCCTS Custom Field"

    Public Property CustomGroupId() As Guid?
        Get
            Dim tmpGuid As Guid
            If EditedAppointmentCopy.CustomFields("CustomGroupId") IsNot Nothing AndAlso Guid.TryParse(EditedAppointmentCopy.CustomFields("CustomGroupId").ToString, tmpGuid) AndAlso tmpGuid <> Guid.Empty Then
                Return tmpGuid
            Else
                Return Nothing
            End If
        End Get
        Set(ByVal value As Guid?)
            EditedAppointmentCopy.CustomFields("CustomGroupId") = value
        End Set
    End Property


    Public Property CustomClassId() As Guid?
        Get
            Dim tmpGuid As Guid
            If EditedAppointmentCopy.CustomFields("CustomClassId") IsNot Nothing AndAlso Guid.TryParse(EditedAppointmentCopy.CustomFields("CustomClassId").ToString, tmpGuid) AndAlso tmpGuid <> Guid.Empty Then
                Return tmpGuid
            Else
                Return Nothing
            End If
        End Get
        Set(ByVal value As Guid?)
            EditedAppointmentCopy.CustomFields("CustomClassId") = value
        End Set
    End Property


    Public Property CustomCategoryId() As Guid?
        Get
            Dim tmpGuid As Guid
            If EditedAppointmentCopy.CustomFields("CustomCategoryId") IsNot Nothing AndAlso Guid.TryParse(EditedAppointmentCopy.CustomFields("CustomCategoryId").ToString, tmpGuid) AndAlso tmpGuid <> Guid.Empty Then
                Return tmpGuid
            Else
                Return Nothing
            End If
        End Get
        Set(ByVal value As Guid?)
            EditedAppointmentCopy.CustomFields("CustomCategoryId") = value
        End Set
    End Property


    Public Property CustomTypeId() As Guid?
        Get
            Dim tmpGuid As Guid
            If EditedAppointmentCopy.CustomFields("CustomTypeId") IsNot Nothing AndAlso Guid.TryParse(EditedAppointmentCopy.CustomFields("CustomTypeId").ToString, tmpGuid) AndAlso tmpGuid <> Guid.Empty Then
                Return tmpGuid
            Else
                Return Nothing
            End If
        End Get
        Set(ByVal value As Guid?)
            EditedAppointmentCopy.CustomFields("CustomTypeId") = value
        End Set
    End Property

    Public Property CustomStatusId() As Guid?
        Get
            Dim tmpGuid As Guid
            If EditedAppointmentCopy.CustomFields("CustomStatusId") IsNot Nothing AndAlso Guid.TryParse(EditedAppointmentCopy.CustomFields("CustomStatusId").ToString, tmpGuid) AndAlso tmpGuid <> Guid.Empty Then
                Return tmpGuid
            Else
                Return Nothing
            End If
        End Get
        Set(ByVal value As Guid?)
            EditedAppointmentCopy.CustomFields("CustomStatusId") = value
        End Set
    End Property

#End Region


    Public Overrides Function IsAppointmentChanged() As Boolean
        Dim hasChanged As Boolean = True

        Return hasChanged
    End Function

    Protected Overrides Sub ApplyCustomFieldsValues()
        MyBase.SourceAppointment.CustomFields("CustomGroupId") = CustomGroupId
        MyBase.SourceAppointment.CustomFields("CustomCategoryId") = CustomCategoryId
        MyBase.SourceAppointment.CustomFields("CustomClassId") = CustomClassId
        MyBase.SourceAppointment.CustomFields("CustomTypeId") = CustomTypeId
        MyBase.SourceAppointment.CustomFields("CustomStatusId") = CustomStatusId
        MyBase.ApplyCustomFieldsValues()
    End Sub

    'Protected Overrides Sub OnLabelIdChanged()
    '    MyBase.OnLabelIdChanged()
    'End Sub
End Class
